<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-31 17:46:49
 * @LastEditTime: 2019-11-28 15:58:02
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../../css/base.css" />
    <link rel="stylesheet" type="text/css" href="../../css/local.css" />
    <link rel="stylesheet" type="text/css" href="../../font/iconfont.css" />
    <link rel="stylesheet" href="../../script/elementui/lib/theme-chalk/index.css?t=1">
    <link href="../../script/elementui/vue-element-table.css" rel="stylesheet" />
    <script type="text/javascript" src="../../script/jquery.js"></script>
    <script type="text/javascript" src="../../script/layer/layer.js"></script>
    <script type="text/javascript" src="../../script/vue.min.js"></script>
    <script type="text/javascript" src="../../script/vant.min.js"></script>
    <script type="text/javascript" src="../../script/fastclick.js"></script>
    <script src="../../script/elementui/lib/index.js?t=1"></script>
    <script src="../../script/elementui/vue-element-bigdata-table.min.js?t=4"></script>
    <script type="text/javascript" src="../../script/base.js"></script>
    <script type="text/javascript" src="../../script/JSLINQ.js"></script>
    <script type="text/javascript" src="../../script/ajaxFileUpload.js"></script>
    <style type="text/css">
        body {
            zoom: 0.9;
        }

        .innerBox {
            flex: 1;
            overflow: auto;
        }

        .mainForm {
            height: auto;
            width: 99%;
            overflow-y: auto;
            display: flex;
            flex-wrap: wrap;
            padding-bottom: 100px;
        }

        .van-field {
            width: 50%;
        }

        .van-field__label {
            width: auto;
        }

        .van-field__label {
            width: 105px;
            color: #969799;
        }

        .subFrame {
            height: auto;
            width: 100%;
            padding-bottom: 50px;
        }

        .title {
            width: 25%;
            background-color: #83bff6;
            text-align: center;
            margin: 2px auto 2px 0;
            padding: 4px 1px;
            color: #fff;
            font-size: 17px;
        }

        .table {
            width: 100%;
            overflow: auto;
            height: auto;
            border-bottom: 0;
            border-right: 0;
            display: flex;
        }

        table {
            white-space: nowrap;
            border-collapse: separate;
            table-layout: fixed;
            top: 0;
            flex: 1;
        }

        .table table th {
            text-align: center;
            padding: auto 5px;
            background-color: lightblue;
            position: sticky;
            top: 0;
            z-index: 1;
        }

        .van-icon-delete {
            color: red;
        }

        td {
            text-align: center;
        }

        .equipmentBox {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
        }

        .equipmentBox .van-tag {
            width: 75%;
            margin-top: 4px;
            margin-right: 8px;
        }

        .tagTitlt {
            width: 90%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            display: inline-block;
        }

        .equipmentBox .van-button {
            width: 10%;
            margin-top: 4px;
        }

        input {
            background: none;
            outline: none;
            border: none;
        }

        .van-dialog__confirm,
        .van-dialog__confirm:active {
            color: #1989fa;
        }

        .van-icon-play-circle-o {
            color: #f5f5f5;
            font-size: 50px;
            vertical-align: middle;
            position: absolute;
            z-index: 1;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .van-cell {
            padding: 10px 8px 10px 12px;
        }

        .form .van-cell__title {
            max-width: 105px;
            color: red;
        }

        /* .form .van-cell__value {
            text-align: left;
        } */

        /* .van-cell::after {
            position: absolute;
            box-sizing: border-box;
            content: ' ';
            pointer-events: none;
            right: 8px;
            bottom: 0;
            left: 12px;
            border-bottom: 1px solid #ebedf0;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5);
        } */
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box" id="box">
            <van-nav-bar id="van-nav-bar" :title="titleName" left-arrow @click-left="onClickLeft">
                <div slot="right">
                    <span slot="right" @click="openScan" v-if="!isPDA">
                        <img src="../../image/scan.png" />
                    </span>
                    <span slot="right" @click="openPrint" v-if="isPDA && printConfig">
                        <img src="../../image/print.png" />
                    </span>
                </div>
            </van-nav-bar>

            <div class="innerBox">
                <div class="mainForm">
                    <van-field v-model="formData.CkNo" label="检验编号" placeholder="请输入检验编号" class='label1' required
                        readonly></van-field>

                    <van-field v-model="formData.GDDH" label="工单号" placeholder="请输入工单号" class='label1' required
                        readonly></van-field>
                    <van-field v-model="formData.CkTime" label="报检日期" placeholder="请输入报检日期" class='label1' required
                        readonly @click="showDate = true">
                    </van-field>
                    <van-field v-model="formData.XXDDBillNO" label="销售订单号" placeholder="请输入销售订单号" readonly></van-field>
                    <van-field v-model="formData.XQDH" label="销售订单行号" placeholder="请输入销售订单行号" readonly></van-field>

                    <van-field v-model="formData.ProductCode" label="产品品号" placeholder="请输入产品品号" class='label1' required
                        readonly>
                    </van-field>
                    <!-- <van-field v-model="formData.ProductName" label="产品信息" placeholder="请输入产品信息" required readonly
                        is-link @click="openBaseScreen('产品')"></van-field> -->
                    <van-field v-model="formData.ProductName" label="产品信息" placeholder="请输入产品信息" class='label1' required
                        readonly>
                    </van-field>
                    </van-field>

                    <van-field v-model="formData.ProductSpec" label="产品规格" placeholder="请输入产品规格"></van-field>

                    <van-field v-model="formData.PHMS" label="产品描述" placeholder="请输入产品描述" readonly></van-field>
                    <van-field v-model="formData.KJM" label="快捷码" placeholder="请输入快捷码" readonly></van-field>

                    <van-field v-model="formData.ProcedureName" label="工序信息" placeholder="请输入工序信息" readonly></van-field>

                    <van-field type='number' v-model="formData.IncomingNumber" label="派工数量" placeholder="请输入派工数量">
                    </van-field>

                    <van-field type='number' v-model="formData.InComingAmount" label="检验数量" placeholder="请输入检验数量"
                        required @blur='handInComingAmount' class='label1'>
                    </van-field>
                    <van-field type='number' v-model="formData.CkAmount" label="合格数量" placeholder="请输入合格数量"
                        class='label1' required @blur="handlerCkAmount('合格数量')"></van-field>
                    <van-field type='number' v-model="formData.BadAmount" label="不良数量" placeholder="请输入不良数量"
                        @blur="handlerCkAmount('不良数量')">
                    </van-field>
                    <!-- <van-field v-model="formData.BadRate" label="不良率" placeholder="请输入不良率"></van-field> -->
                    <van-field v-model="formData.JYJG" label="检验结果" class='label1' placeholder="请输入检验结果" readonlly
                        is-link @click="handlerJYJG"></van-field>
                    <van-field v-model="formData.EmplName" label="检验员" placeholder="请输入检验员" readonly>
                    </van-field>

                    <!-- <van-field v-model="formData.JYXM" label="检验项目" placeholder="请输入检验项目" readonly is-link
                        @click="handlerJYXM">
                    </van-field> -->

                    <van-cell title="检验项目" style="width: 50%;" class="form" @click="handlerJYXM()">
                        <div>
                            <van-tag v-for="(row,index) in formData.ProcedureList" size="large" type="primary"
                                style="margin-right: 3px;">{{row.name.split('|')[0]}}
                            </van-tag>
                        </div>
                        <van-icon slot="right-icon" name="arrow" size="18px"></van-icon>
                    </van-cell>

                    <!-- <van-field v-model="formData.EmplName" label="检验员" placeholder="请输入检验员" readonly is-link
                        @click="openBaseScreen('检验员')">
                    </van-field> -->
                    <!-- <van-field v-model="formData.SCRY" label="生产人员" placeholder="请输入生产人员" required readonly is-link
                        @click="openBaseScreen('生产人员')"></van-field> -->
                    <van-field v-model="formData.Approve" label="审核状态" placeholder="请输入审核状态" readonly></van-field>
                    <van-field v-model="formData.Approver" label="审核人" placeholder="请输入审核人" readonly></van-field>
                    <van-field v-model="formData.ApproveTime" label="审核时间" placeholder="请输入审核时间" readonly></van-field>
                    <!-- <van-field v-model="formData.Weight" label="重量" placeholder="请输入重量"></van-field> -->
                    <!-- <van-field v-model="formData.CZResult" label="处置结果" placeholder="处置结果" readonly is-link
                        @click="handlerResult"></van-field> -->
                    <van-field name="uploader" label="现场图片" readonly style='width: 100%;'>
                        <template #input>
                            <div class="van-uploader">
                                <!-- 整行图片 -->
                                <div class="van-uploader__wrapper">
                                    <!-- 单个照片 -->
                                    <div class="van-uploader__preview" v-for="(item, index) in imgList">
                                        <van-image @click="previewImg" width="80" height="80"
                                            :src="serverIP + item.url">
                                        </van-image>
                                        <div @click="deleteImg(index)" class="van-uploader__preview-delete"
                                            style="width: 30px; height: 30px">
                                            <i class="van-icon van-icon-cross van-uploader__preview-delete-icon"
                                                style="font-size: 30px"></i>
                                        </div>
                                    </div>

                                    <!-- 上传图片的按钮 -->
                                    <div v-show="imgList.length < 9" class="van-uploader__upload"
                                        @change="uploadNewFile(1)">
                                        <i
                                            class="van-badge__wrapper van-icon van-icon-photograph van-uploader__upload-icon"></i>
                                        <input type="file" name="newFile1" id="newFile1" accept="image/*"
                                            class="van-uploader__input">
                                    </div>
                                </div>
                            </div>
                        </template>
                    </van-field>

                    <van-field name="uploader" label="现场视频" readonly style='width: 100%;'>
                        <template #input>
                            <div class="van-uploader">
                                <!-- 整行图片 -->
                                <div class="van-uploader__wrapper">
                                    <!-- 单个照片 -->
                                    <div class="van-uploader__preview" v-for="(item, index) in videoImgList">
                                        <!-- <van-icon name="play-circle-o" @click="previewVideo(index)"></van-icon> -->
                                        <!-- <van-image width="80" height="80" :src="serverIP + item.url"> -->
                                        <van-image width="80" height="80" :src="item.url" @click="previewVideo(index)">
                                        </van-image>
                                        <div @click="deleteVideo(index)" class="van-uploader__preview-delete"
                                            style="width: 30px; height: 30px">
                                            <i class="van-icon van-icon-cross van-uploader__preview-delete-icon"
                                                style="font-size: 30px"></i>
                                        </div>
                                    </div>

                                    <!-- 上传图片的按钮 -->
                                    <div v-show="videoImgList.length < 9" class="van-uploader__upload"
                                        @change="uploadNewFile(2)">
                                        <i
                                            class="van-badge__wrapper van-icon van-icon-photograph van-uploader__upload-icon"></i>
                                        <input type="file" name="newFile2" id="newFile2" accept="video/*"
                                            class="van-uploader__input">
                                    </div>
                                </div>
                            </div>
                        </template>
                    </van-field>
                    <van-field v-model="formData.FRemarks" label="备注" placeholder="请输入备注">
                    </van-field>
                </div>

                <!-- <div class="subFrame">
                    <div class="title">首件检明细</div>
                    <div class="table" id="table">
                        <table style="width: auto;">
                            <tr>
                                <th>序号</th>
                                <th>所属分类<van-icon name="arrow-down"></van-icon>
                                </th>
                                <th>检验项目<van-icon name="arrow-down"></van-icon>
                                </th>
                                <th>工序<van-icon name="arrow-down"></van-icon>
                                </th>
                                <th>工序说明</th>
                                <th>检验标准</th>
                                <th>检验工具</th>
                                <th>上极限</th>
                                <th>下极限</th>
                                <th>最大值</th>
                                <th>最小值</th>
                                <th>判定结果</van-icon>
                                </th>
                                <th>设备<van-icon name="arrow-down"></van-icon>
                                </th>
                                <th>模具<van-icon name="arrow-down"></van-icon>
                                </th>
                            </tr>

                            <tr v-for="(item, index) in tableData">
                                <td>
                                    {{index + 1}}
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.InspectionTypeName"
                                        @click="openBaseScreen('所属分类', index)"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.FQCItemName"
                                        @click="openBaseScreen('检验项目', index)"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.ProcedureName"
                                        @click="openBaseScreen('子工序', index)"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.GXSM"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.JYBZ"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.Benchmark"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.PoorWork"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.PoorNormally"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.JYJG1"
                                        @input="handlerJYJG1(item, index, '实测值1')"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.JYJG2"
                                        @input="handlerJYJG1(item, index, '实测值2')"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.FResult1"
                                        @click="handlerFResult1(item, index)" readonly></input> 
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.EquipmentName"></input>
                                </td>
                                <td>
                                    <input style="width: 100%;" type="text" v-model="item.MoludName"></input>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div> -->

                <div class="bottomSubmit"
                    style="position: fixed;bottom: 0px;z-index: 1;width: 100%;padding: 5px 10px;right:0px">
                    <div style="float:left;width:10%;margin-left: 10px;">
                        <van-button round block type="info" native-type="submit" @click="toOffice(1)">品号文档
                        </van-button>
                    </div>
                    <div style="float:left;width:10%;margin-left: 5px;">
                        <van-button round block type="info" native-type="submit" @click="toOffice(2)">销售订单文档
                        </van-button>
                    </div>
                    <div style="float:left;width:10%;margin-left: 5px;">
                        <van-button round block type="info" native-type="submit" @click="toOffice(3)">快捷码文档
                        </van-button>
                    </div>
                    <!-- <div style="float:left;width:10%;margin-left: 5px;">
                        <van-button round block type="info" native-type="submit" @click="toOffice(4)">彩稿文档
                        </van-button>
                    </div> -->
                    <div style="float:right;width:20%;">
                        <van-button round block type="info" v-show="formData.Approve == '未审核'" native-type="submit"
                            @click="saveRow">编辑</van-button>
                    </div>
                    <div style="float:right;width:20%;">
                        <van-button v-show="showUnqualified" round block type="info" native-type="submit"
                            @click="dialogShow = true">发起不合格评审
                        </van-button>
                    </div>

                    <div style="float:right;width:20%;">
                        <van-button round block type="info" native-type="submit" @click="submit(-1)"
                            v-if="formData.Approve == '已审核'">取消审核</van-button>
                        <van-button round block type="info" native-type="submit" @click="submit(1)"
                            v-if="formData.Approve == '未审核'">审核</van-button>
                    </div>
                </div>
            </div>

            <van-popup position="bottom" v-model="showDate">
                <van-datetime-picker v-model="currentDate" type="date" title="选择报检日期" @confirm="confirmDate"
                    @cancel="showDate = false"></van-datetime-picker>
            </van-popup>

            <van-action-sheet v-model="showFResult1" :actions="FResult1Actions" @select="onSelectFResult1">
            </van-action-sheet>

            <van-action-sheet v-model="showJYJG" :actions="JYJGActions" @select="onSelectJYJG">
            </van-action-sheet>

            <!-- <van-action-sheet v-model="showJYXM" :actions="JYXMActions" @select="onSelectJYXMA">
            </van-action-sheet> -->
            <van-action-sheet v-model="showJYXM" title="标题">
                <div v-for='item,index in JYXMActions' :key='index' @click='onSelectJYXMA(item)'>{{item.name}}</div>
            </van-action-sheet>

            <van-popup position="bottom" v-model="showOffice">
                <van-tree-select :items="officeItems" :active-id.sync="officeActiveId"
                    :main-active-index.sync="officeActiveIndex" @click-item="onClickItem" @click-nav="onClickNav">
                </van-tree-select>
            </van-popup>

            <van-dialog v-model="dialogShow" title="请填写异常描述" show-cancel-button @confirm="handlerDialog"
                @cancel="dialogShow = false">
                <van-field style="width: 100%; margin-top: 10px;" v-model="unqualifiedData.Content" label="异常描述"
                    placeholder="请输入异常描述">
                </van-field>
            </van-dialog>

            <van-action-sheet v-model="showResult" :actions="ResultActions" @select="onSelectResult">
            </van-action-sheet>
        </div>
    </div>
</body>

<script type="text/javascript">

    var vm;
    apiready = function () {

        var FNScanner = api.require('FNScanner');
        var scanTC80 = api.require('scanTC80');
        var escPrinter = api.require('escPrinter');
        var scanS60A = api.require('ScanS60A');
        var scanDT40 = api.require('scanDT40');
        var FNPhotograph = api.require('FNPhotograph');
        var photoBrowser = api.require('photoBrowser');
        var docReader = api.require('docReader');
        var mediaCollector = api.require('mediaCollector');

        api.addEventListener({
            name: 'selectRow'
        }, function (ret, err) {
            // console.log('ret', JSON.stringify(ret))
            if (ret.value.type == '产品') {
                vm.formData.productName = ret.value.row.name
                vm.formData.ProductCode = ret.value.row.ProductCode
            } else if (ret.value.type == '主工序') {
                vm.formData.Procedure = ret.value.row.name
                vm.formData.ProcedureID = ret.value.row.ProcedureID
            }
            else if (ret.value.chooseType == '项目多选') {
                console.log('ret.value.row', JSON.stringify(ret.value.row))

                vm.formData.ProcedureList = ret.value.row
                vm.$forceUpdate()

                // vm.formData.ProcedureList.map((item) => {
                //     var obj = {
                //         ProcedureID: item.ProcedureID,
                //         QrCode: vm.formData.QrCode,
                //         BB: vm.formData.BB
                //     }
                //     console.log('obj', JSON.stringify(obj))
                //     APP.ajax('selectGXIDByXJMX', obj, function (res) {
                //         console.log('res', JSON.stringify(res))
                //         res.ds.map((item) => {
                //             item.InspectionTypeName = item.UpID_show
                //             item.FQCItemName = item.FQCItemID_show
                //             item.Benchmark = item.FQCItemID_show
                //             item.FResult1 = item.FResult == '1' ? '合格' : '不合格'
                //         })
                //         vm.checkTableData.push(...res.ds)
                //     })
                // })
            }
            else if (ret.value.type == '子工序') {
                vm.tableData[vm.currentIndex].ProcedureName = ret.value.row.name
                vm.tableData[vm.currentIndex].ProcedureID = ret.value.row.ProcedureID
            } else if (ret.value.type == '检验员') {
                vm.formData.checkMan = ret.value.row.name
                vm.formData.checkManID = ret.value.row.EmplID
            } else if (ret.value.type == '所属分类') {
                vm.tableData[vm.currentIndex].InspectionTypeName = ret.value.row.name
                vm.tableData[vm.currentIndex].UpID = ret.value.row.InspectionTypeID
            } else if (ret.value.type == '检验项目') {
                vm.tableData[vm.currentIndex].FQCItemName = ret.value.row.name
                vm.tableData[vm.currentIndex].FQCItemID = ret.value.row.FQCItemID
            } else if (ret.value.type == '设备') {
                ret.value.row.EquipmentName = ret.value.row.name
                if (vm.tableData[vm.currentIndex].totalEquipment.length) {
                    vm.tableData[vm.currentIndex].totalEquipment.map((item) => {
                        if (item.EquipmentID == ret.value.row.EquipmentID) {
                            vm.$toast(ret.value.row.name + '设备已存在！');
                        } else {
                            vm.tableData[vm.currentIndex].totalEquipment.push(ret.value.row)
                            vm.tableData[vm.currentIndex].EquipmentName = vm.tableData[vm.currentIndex].totalEquipment.map(i => i.EquipmentName).join(',')
                            vm.tableData[vm.currentIndex].EquipmentID = vm.tableData[vm.currentIndex].totalEquipment.map(i => i.EquipmentID).join(',')
                        }
                    })
                } else {
                    vm.tableData[vm.currentIndex].totalEquipment.push(ret.value.row)
                    vm.tableData[vm.currentIndex].EquipmentName = vm.tableData[vm.currentIndex].totalEquipment.map(i => i.EquipmentName).join(',')
                    vm.tableData[vm.currentIndex].EquipmentID = vm.tableData[vm.currentIndex].totalEquipment.map(i => i.EquipmentID).join(',')
                }
            } else if (ret.value.type == '模具') {
                ret.value.row.MoludName = ret.value.row.name
                if (vm.tableData[vm.currentIndex].totalMolud.length) {
                    vm.tableData[vm.currentIndex].totalMolud.map((item) => {
                        if (item.MoludID == ret.value.row.MoludID) {
                            vm.$toast(ret.value.row.name + '模具已存在！');
                        } else {
                            vm.tableData[vm.currentIndex].totalMolud.push(ret.value.row)
                            vm.tableData[vm.currentIndex].MoludName = vm.tableData[vm.currentIndex].totalMolud.map(i => i.MoludName).join(',')
                            vm.tableData[vm.currentIndex].MoludID = vm.tableData[vm.currentIndex].totalMolud.map(i => i.MoludID).join(',')
                        }
                    })
                } else {
                    vm.tableData[vm.currentIndex].totalMolud.push(ret.value.row)
                    vm.tableData[vm.currentIndex].MoludName = vm.tableData[vm.currentIndex].totalMolud.map(i => i.MoludName).join(',')
                    vm.tableData[vm.currentIndex].MoludID = vm.tableData[vm.currentIndex].totalMolud.map(i => i.MoludID).join(',')
                }

            } else if (ret.value.type == '生产人员') {
                vm.formData.SCRY = ret.value.row.name
                vm.formData.SCRYID = ret.value.row.userid_num
            }
        })

        vm = new Vue({
            el: '#app',
            data: {
                titleName: api.pageParam.titleName,
                isPDA: api.deviceModel.indexOf('PDA') > -1 ? true : false,
                serverIP: APP.serverIP(),
                printConfig: '',
                showDate: false,
                currentDate: new Date(),
                showFResult1: false,
                FResult1Actions: [],
                imgList: [],
                formData: {
                    FRemarks: '',
                    XXDDBillNO: '',
                    XXDDID: '',
                    XQDH: '',
                    PHMS: '',
                    KJM: '',
                    ProcedureList: [],
                    CkNo: '',
                    FQCCkID: '',
                    CkTime: '',
                    ProductName: '',
                    ProductCode: '',
                    CPTH: '',
                    ProcedureName: '',
                    ProcedureID: '',
                    IncomingNumber: 0,
                    InComingAmount: 0,
                    CkAmount: 0,
                    BadAmount: '',
                    BadRate: 0,
                    EmplName: '',
                    EmplID: '',
                    FilePath: '',
                    Approve: '',
                    Approver: '',
                    ApproveTime: '',
                    SCRYID: '',
                    SCRY: '',
                    JYJG: '',
                    JYJGID: '',
                    Weight: '',
                    CZResult: ''
                },
                JYJGActions: [],
                showJYJG: false,
                JYXMActions: [],
                showJYXM: false,
                JYJGAIDList: [],
                JYJGANameList: [],
                tableData: [
                    {
                        CheckDetailDeID: '',
                        UpID: '',
                        InspectionTypeName: '',
                        FQCItemID: '',
                        FQCItemName: '',
                        ProcedureID: '',
                        ProcedureName: '',
                        GXSM: '',
                        JYBZ: '',
                        Benchmark: '',
                        PoorWork: '',
                        PoorNormally: '',
                        FQCItemID: '',
                        FQCItemName: '',
                        JYJG1: '',
                        FResult: '',
                        FResult1: '',
                        MoludID: '',
                        MoludName: '',
                        EquipmentName: '',
                        EquipmentID: '',
                    }
                ],
                activeSubFrame: '1',
                currentIndex: 0,
                showOffice: false,
                officeItems: [],
                officeActiveId: 0,
                officeActiveIndex: 0,
                dialogShow: false,
                unqualifiedData: {
                    Content: '',
                },
                showUnqualified: false,
                videoList: [],
                videoImgList: [],
                showResult: false,
                ResultActions: [],
                saveFlag: 1
            },
            created: function () {
                var that = this

                if (api.pageParam.historyData) {
                    that.imgList = []
                    that.videoList = []
                    that.videoImgList = []
                    var obj
                    if (api.pageParam.titleName == '检验任务池') {
                        obj = {
                            FQCCkID: api.pageParam.historyData.ID
                        }
                    } else {
                        obj = {
                            FQCCkID: api.pageParam.historyData.FQCCkID
                        }
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('APP_SJJMX', obj, function (res) {
                        console.log('572res', JSON.stringify(res))

                        that.formData = res.ds[0]
                        that.formData.BadAmount = res.ds[0].BadAmount

                        that.formData.ProductName = res.ds[0].ITEM_NAME
                        if (res.ds[0].JYXMID) {
                            var JYXM = res.ds[0].JYXM.split(',')
                            var JYXMID = res.ds[0].JYXMID.split(',')
                            var arr = []
                            JYXM.map((item, index) => {
                                var obj
                                JYXMID.map((it, ii) => {
                                    if (index == ii) {
                                        obj = {
                                            name: item,
                                            ID: it,
                                        }
                                    }
                                })
                                arr.push(obj)
                            })
                            that.formData.ProcedureList = arr
                        }


                        console.log('ProcedureList', JSON.stringify(that.formData.ProcedureList))

                        if (that.formData.FilePath && that.formData.FilePath != 'null') {
                            var arr = that.formData.FilePath.split(',')
                            arr.map((item) => {
                                that.imgList.push({ url: item })
                            })
                        } else {
                            that.imgList = []
                        }

                        if (that.formData.FilePath1 && that.formData.FilePath1 != 'null') {
                            var arr = that.formData.FilePath1.split(',')
                            arr.map((item) => {
                                that.videoList.push({ url: item })
                            })
                        } else {
                            that.videoList = []
                        }

                        if (that.formData.FilePath2 && that.formData.FilePath2 != 'null') {
                            var arr = that.formData.FilePath2.split(',')
                            arr.map((item) => {
                                that.videoImgList.push({ url: item })
                            })
                        } else {
                            that.videoImgList = []
                        }

                        // res.ds1.map((item) => {
                        //     item.FResult = item.FResult1 == '不合格' ? 2 : 1
                        // })
                        // that.tableData = res.ds1
                        // that.checkShowUnqualified(that.tableData)
                        // console.log('that.tableData', JSON.stringify(that.tableData))
                    })
                }
            },
            mounted() {
                var navBar = document.getElementById('van-nav-bar')
                navBar.style.paddingTop = api.safeArea.top + 'px'

                let height = document.documentElement.clientHeight
                window.onresize = () => { // 在页面大小发生变化时调用
                    // 把获取到的高度赋值给根div
                    document.getElementById('app').style.height = height + 'px'
                }
            },
            methods: {
                onClickLeft() {
                    api.closeWin();
                },
                onSelectResult(val) {
                    var that = this
                    that.formData.CZResult = val.name
                    that.showResult = false
                },

                handlerResult() {
                    var that = this
                    APP.ajax('PZJLPD_XL', { JYLX: 2 }, function (res) {
                        console.log('res', JSON.stringify(res))
                        res.ds.map((item) => {
                            item.name = item.NAME
                        })
                        that.ResultActions = res.ds
                        that.showResult = true
                    })
                },
                previewVideo(videoIndex) {
                    var that = this
                    console.log('videoPath', JSON.stringify(that.serverIP + that.videoList[videoIndex].url))
                    mediaCollector.videoPreview({
                        videoPath: that.serverIP + that.videoList[videoIndex].url
                    });
                },

                deleteVideo(index) {
                    var that = this
                    that.videoList.splice(index, 1)
                    that.videoImgList.splice(index, 1)
                },

                addVideo() {
                    var that = this
                    document.activeElement.blur();
                    mediaCollector.openCamera({
                        shootMode: 2,
                    }, function (ret, err) {
                        // alert('ret' + JSON.stringify(ret))
                        if (ret.type === 'video') {
                            that.$toast('视频上传中...')
                            APP.uploadFile('首件检', ret.path, function (videoPath) {
                                // console.log('videoPath', JSON.stringify(videoPath))
                                that.videoList.push({ url: videoPath })
                                // console.log('videoList', JSON.stringify(that.videoList))
                            })
                            APP.uploadFile('首件检', ret.videoThumbnailPath, function (imgPath) {
                                // console.log('imgPath', JSON.stringify(imgPath))
                                that.videoImgList.push({ url: imgPath })
                                // console.log('videoImgList', JSON.stringify(that.videoImgList))
                            })
                        }
                    });
                },

                checkShowUnqualified(array) {
                    var that = this
                    var arr = array.map(item => item.FResult)
                    console.log('arr', JSON.stringify(arr))
                    if (arr.indexOf(2) == -1) {  //没有不合格
                        that.showUnqualified = false
                        that.formData.JYJG = '合格'
                        that.formData.JYJGID = 2
                    } else {
                        that.showUnqualified = true
                        that.formData.JYJG = '不合格'
                        that.formData.JYJGID = 1
                    }
                },
                deleteProcedure(procedureIndex) {
                    var that = this
                    that.formData.ProcedureList.splice(procedureIndex, 1)
                    vm.$forceUpdate()
                },
                // handlerJYXM() {
                //     var that = this
                //     APP.ajax('APP_JYRWC_JYXMDX', {}, function (res) {
                //         console.log('res', JSON.stringify(res))

                //         that.JYXMActions = res.ds
                //         that.JYXMActions.map(item => item.name = item.NAME)
                //     })
                //     that.showJYXM = true
                // },
                handlerJYXM() {
                    var that = this
                    var obj = {
                        currentList: that.formData.ProcedureList,
                        cmdObj: {

                        },
                        cmd: 'APP_JYRWC_JYXMDX',
                        type: '项目多选',
                    }
                    api.openWin({
                        name: 'multipleChoice',
                        url: '../tool/multipleChoice.html',
                        reload: true,
                        slidBackEnabled: false,
                        pageParam: obj
                    })
                },



                handlerJYJG() { //主表检验结果
                    var that = this
                    APP.ajax('APP_LLJ_JYJGXL', {}, function (res) {
                        // console.log('res', JSON.stringify(res))
                        that.JYJGActions = res.ds
                    })
                    that.showJYJG = true
                },
                onSelectJYXMA(val) {
                    var that = this
                    console.log('val', JSON.stringify(val))
                    // that.formData.ID = val.id
                    // that.formData.NAME = val.name
                    that.formData.JYJGAIDList = that.formData.JYJGAIDList.push(val.ID)
                    that.formData.JYJGANameList = that.formData.JYJGAIDList.push(val.name)
                    // that.showJYXM = false
                },

                onSelectJYJG(val) {
                    var that = this
                    that.formData.JYJG = val.name
                    that.formData.JYJGID = val.id
                    that.showJYJG = false
                },

                handlerDialog() {
                    var that = this
                    if (!that.unqualifiedData.Content) {
                        api.toast({
                            msg: '请填写异常内容!'
                        })
                        return false
                    }
                    var obj = {
                        Content: that.unqualifiedData.Content,
                        JYLX: 2,
                        FkeyID: that.formData.FQCCkID,
                        APFlowID: 5
                    }
                    console.log('obj', JSON.stringify(obj))
                    APP.ajax('APP_ZDSCBHGPS', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (res.ds[0].status == 200) {
                            that.dialogShow = false
                            that.saveRow()

                            api.openWin({
                                name: 'unqualified',
                                url: 'unqualified.html',
                                reload: true,
                                slidBackEnabled: false,
                                pageParam: {
                                    titleName: '不合格评审',
                                    historyData: {
                                        BadReviewID: res.ds1[0].BadReviewID,
                                        InformationSource: that.titleName,
                                    }
                                }
                            })
                        }
                        api.toast({
                            msg: res.ds[0].msg
                        })
                    })
                },

                confirmDate() {
                    var that = this
                    that.formData.date = APP.getFormatDateTime(that.currentDate).split(' ')[0]
                    that.showDate = false
                },
                handlerFResult1(item, index) {
                    var that = this
                    that.currentIndex = index
                    if (!item.PoorWork && !item.PoorNormally) {
                        APP.ajax('SJJ_PDJGXL', {}, function (res) {
                            // console.log('res', JSON.stringify(res))
                            that.FResult1Actions = res.ds
                        })
                        that.showFResult1 = true
                    }
                },

                onSelectFResult1(val) {
                    var that = this
                    that.tableData[that.currentIndex].FResult = val.ID
                    that.tableData[that.currentIndex].FResult1 = val.name
                    that.showFResult1 = false
                    // that.checkShowUnqualified(that.tableData)
                },

                tableDelete(deleteItem) {
                    var that = this
                    that.tableData = that.tableData.filter((item) => {
                        return item.CheckDetailDeID != deleteItem.CheckDetailDeID
                    })
                },

                previewImg() {
                    var that = this
                    document.activeElement.blur();
                    var imgFlag = 0
                    var imageArr = []
                    that.imgList.map((item) => {
                        imageArr.push(that.serverIP + item.url)
                    })
                    photoBrowser.open({
                        images: imageArr,
                        bgColor: '#000'
                    }, function (ret, err) {
                        if (ret) {
                            // alert(JSON.stringify(ret));
                            if (ret.eventType == 'show') {
                                imgFlag = 1
                            }
                            if (ret.eventType == 'click') {
                                imgFlag = 0
                                photoBrowser.close();
                            }
                        } else {
                            layer.open({
                                content: '图片打开失败，请重试！',
                                skin: 'msg',
                                time: 2
                            });
                        }
                    });
                },

                deleteImg(index) {
                    var that = this
                    that.imgList.splice(index, 1)
                },
                uploadNewFile(index) {
                    var that = this
                    if (index == 1) {
                        var url = APP.serverIP() + '/Frame/uploadImgFile?dirName=首件检';
                    } else {
                        var url = APP.serverIP() + '/Frame/uploadFile?dirName=首件检';
                    }
                    $.ajaxFileUpload({
                        type: 'POST',
                        url: url,
                        secureuri: false,
                        fileElementId: 'newFile' + index,
                        dataType: 'json',
                        success: function (datas, status) {
                            if (datas.status == 200) {
                                console.log('1178datas', JSON.stringify(datas))
                                if (index == 1) {
                                    that.imgList.push({ url: datas.data.origin })
                                }
                                else if (index == 2) {
                                    that.videoList.push({ url: datas.data })
                                    var img = '../../image/Flash.png'
                                    that.videoImgList.push({ url: img })
                                }
                            } else {
                                vm.$toast('上传失败');
                            }
                        },
                        error: function (data, status, e) {
                            console.log('失败data', JSON.stringify(data))
                        }

                    });

                },


                addImg() {
                    var that = this
                    document.activeElement.blur();
                    FNPhotograph.open({
                        path: 'fs://savePath',
                        album: true,
                        quality: 'medium'
                    }, function (ret) {
                        // alert(JSON.stringify(ret));
                        if (ret.eventType == 'takePhoto') {
                            that.$toast('照片上传中...')
                            APP.uploadFile('首件检', ret.imagePath, function (path) {
                                console.log('path', JSON.stringify(path))
                                that.imgList.push({ url: path })
                            })
                            FNPhotograph.close(
                                function (ret) {
                                    if (ret) {
                                        // alert(JSON.stringify(ret));
                                    }
                                });
                        } else if (ret.eventType == 'cameraError') {
                            that.$toast('相机打开失败，请重试！')
                        }
                    });
                },

                handlerJYJG1(item, index) {
                    var that = this
                    that.currentIndex = index
                    // if (item.JYJG1 && item.JYJG2 && item.JYJG3 && item.PoorWork && item.PoorNormally) {
                    // if (Number(item.JYJG1) > item.PoorWork || Number(item.JYJG1) < item.PoorNormally || Number(item.JYJG2) > item.PoorWork || Number(item.JYJG2) < item.PoorNormally || Number(item.JYJG3) > item.PoorWork || Number(item.JYJG3) < item.PoorNormally) {
                    if (item.JYJG1 && item.JYJG2 && item.PoorWork && item.PoorNormally) {
                        if (Number(item.JYJG1) > item.PoorWork || Number(item.JYJG1) < item.PoorNormally || Number(item.JYJG2) > item.PoorWork || Number(item.JYJG2) < item.PoorNormally) {
                            item.FResult1 = '不合格'
                            item.FResult = 2
                            that.formData.JYJG = '不合格'
                            that.formData.JYJGID = 1
                        } else {
                            item.FResult1 = '合格'
                            item.FResult = 1
                        }
                        // that.checkShowUnqualified(that.tableData)
                    }
                },

                deleteEquipment(equipmentItem, index) {
                    var that = this
                    that.currentIndex = index
                    that.tableData[index].totalEquipment = that.tableData[index].totalEquipment.filter((item) => {
                        return item.EquipmentID != equipmentItem.EquipmentID
                    })
                    that.tableData[index].EquipmentName = that.tableData[index].totalEquipment.map(item => item.EquipmentName).join(',')
                    that.tableData[index].EquipmentID = that.tableData[index].totalEquipment.map(item => item.EquipmentID).join(',')
                },

                deletetotalMolud(moludItem, index) {
                    var that = this
                    that.currentIndex = index
                    that.tableData[index].totalMolud = that.tableData[index].totalMolud.filter((item) => {
                        return item.MoludID != moludItem.MoludID
                    })
                    that.tableData[index].MoludName = that.tableData[index].totalMolud.map(item => item.MoludName).join(',')
                    that.tableData[index].MoludID = that.tableData[index].totalMolud.map(item => item.MoludID).join(',')
                },
                handInComingAmount() {
                    var that = this
                    if (Number(that.formData.InComingAmount) >= 0) {
                        that.formData.CkAmount = that.formData.InComingAmount
                        that.formData.BadAmount = ''
                    }
                    else {
                        that.formData.InComingAmount = ''
                    }
                },
                handlerCkAmount(title) {
                    var that = this
                    console.log('title', title)

                    if (title == '合格数量') {
                        if (Number(that.formData.CkAmount) >= 0) {
                            if (Number(that.formData.CkAmount) > Number(that.formData.InComingAmount)) {
                                api.toast({
                                    msg: '合格数量不能大于检验数量'
                                })
                                that.formData.CkAmount = ''
                            }
                            else {
                                that.formData.BadAmount = Number(that.formData.InComingAmount) - Number(that.formData.CkAmount)
                                if (Number(that.formData.BadAmount) < 0) {
                                    that.formData.BadAmount = ''
                                    api.toast({
                                        msg: '不良数量不能小于0'
                                    })
                                }
                            }
                        }
                        else {
                            that.formData.CkAmount = ''
                            api.toast({
                                msg: '合格数量不能小于0'
                            })
                        }

                    }

                    else {
                        if (Number(that.formData.BadAmount) >= 0) {

                            if (Number(that.formData.BadAmount) > Number(that.formData.InComingAmount)) {
                                api.toast({
                                    msg: '不良数量不能大于检验数量'
                                })
                                that.formData.BadAmount = ''

                            }

                            else {
                                that.formData.CkAmount = Number(that.formData.InComingAmount) - Number(that.formData.BadAmount)
                                if (Number(that.formData.CkAmount) < 0) {
                                    that.formData.CkAmount = ''
                                    api.toast({
                                        msg: '合格数量不能小于0'
                                    })
                                }
                            }

                        }
                        else {
                            that.formData.BadAmount = ''
                            api.toast({
                                msg: '不合格数量不能小于0'
                            })
                        }

                    }
                    console.log('title', that.formData.BadAmount)
                    console.log('title', that.formData.CkAmount)
                },


                // handlerCkAmount(title) {
                //     var that = this
                //     if (that.formData.CkAmount > that.formData.InComingAmount) {
                //         vm.$toast('合格数量不能大于检验数量！');
                //     }
                //     else {
                //         if (that.formData.InComingAmount) {
                //             if (title == '合格数量') {
                //                 that.formData.CkAmount = that.formData.InComingAmount - that.formData.BadAmount
                //                 if (Number(that.formData.CkAmount) < 0) {
                //                     that.formData.CkAmount = ''
                //                 }
                //             } else {
                //                 that.formData.BadAmount = that.formData.InComingAmount - that.formData.CkAmount

                //                 if (Number(that.formData.BadAmount) < 0) {
                //                     that.formData.BadAmount = ''
                //                 }
                //             }
                //         }
                //         // that.formData.BadRate = that.formData.BadAmount * 100 / that.formData.InComingAmount
                //     }
                // },

                handlerInComingAmount() {
                    var that = this
                    if (that.formData.InComingAmount > that.formData.IncomingNumber) {
                        vm.$toast('检验数量不能大于派工数量！');
                    }
                    if (that.formData.CkAmount > that.formData.InComingAmount) {
                        vm.$toast('合格数量不能大于检验数量！');
                    }
                },

                saveRow(num) {
                    that = this
                    // if (!vm.formData.SCRYID) {
                    //     api.toast({
                    //         msg: '请选择生产人员！'
                    //     })
                    //     return false
                    // }
                    // if (that.saveFlag) {
                    var show = true
                    if (!that.formData.InComingAmount) {
                        var msg = '检验数量未填！'
                        api.toast({
                            msg: msg
                        })
                        show = false
                    }
                    else if (!that.formData.CkAmount) {
                        var msg = '合格数量未填！'
                        api.toast({
                            msg: msg
                        })
                        show = false
                    }
                    else if (!that.formData.BadAmount) {
                        var msg = '不良数量未填！'
                        api.toast({
                            msg: msg
                        })
                        show = false
                    }
                    else if (!that.formData.EmplName) {
                        var msg = '检验员未填！'
                        api.toast({
                            msg: msg
                        })
                        show = false
                    }
                    else if (!that.formData.JYJG) {
                        var msg = '检验结果未填！'
                        api.toast({
                            msg: msg
                        })
                        show = false
                    }

                    if (show) {
                        if (num == -1) {
                            var obj = {
                                Type: num,
                                FQCCkID: that.formData.FQCCkID
                            }
                            // console.log('obj', JSON.stringify(obj))

                            if (api.pageParam.titleName == '检验任务池') {
                                return
                            } else {
                                APP.ajax('APP_SHFStockID_1692319956859', obj, function (res) {
                                    console.log('res', JSON.stringify(res))
                                    if (res.ds[0].status == 500) {
                                        vm.$toast(res.ds[0].msg);
                                    }
                                    else {
                                        vm.$toast('取消审核成功！');
                                        var obj1 = {
                                            Type: num,
                                            FkeyID: that.formData.FQCCkID,
                                        }
                                        APP.ajax('P_SendPollCheck', obj1, function (res) {
                                            api.sendEvent({
                                                name: 'refresh'
                                            })
                                            api.closeWin()
                                        })

                                    }
                                })

                            }

                        }
                        else {
                            that.saveFlag = 0
                            var obj = {
                                JYJG1: that.tableData.map(item => item.JYJG1).join('~'),
                                CheckDetailDeID: that.tableData.map(item => item.CheckDetailDeID).join('~'),
                                ProcedureID: that.tableData.map(item => item.ProcedureID).join('~'),
                                FQCItemID: that.tableData.map(item => item.FQCItemID).join('~'),
                                GXSM: that.tableData.map(item => item.GXSM).join('~'),
                                JYBZ: that.tableData.map(item => item.JYBZ).join('~'),
                                UpID: that.tableData.map(item => item.UpID).join('~'),
                                FResult: that.tableData.map(item => item.FResult).join('~'),
                                FQCCkID: that.formData.FQCCkID,
                                Benchmark: that.tableData.map(item => item.Benchmark).join('~'),
                                PoorWork: that.tableData.map(item => item.PoorWork).join('~'),
                                PoorNormally: that.tableData.map(item => item.PoorNormally).join('~'),
                                JYJG2: that.tableData.map(item => item.JYJG2).join('~'),

                                CkAmount: that.formData.CkAmount,
                                InComingAmount: that.formData.InComingAmount,
                                FilePath: that.imgList.map(item => item.url).join(','),
                                SCRY: that.formData.SCRYID,
                                FilePath1: that.videoList.map(item => item.url).join('~'),
                                FilePath2: that.videoImgList.map(item => item.url).join('~'),
                                Weight: that.formData.Weight ? that.formData.Weight : 0,
                                JYJG: that.formData.JYJGID,
                                BadAmount: that.formData.BadAmount,
                                JYXM: that.formData.ProcedureList.map(item => item.ID).join(','),
                                FRemarks: that.formData.FRemarks
                            }
                            console.log('obj', JSON.stringify(obj))
                            APP.ajax('APP_SJJ_UPDATE', obj, function (res) {
                                console.log('res', JSON.stringify(res))
                                if (res.ds[0].status == 200) {
                                    var updateObj = {
                                        CheckDetailDeID: that.tableData.map(item => item.CheckDetailDeID).join('~'),
                                        P_UserName: APP.getUserInfo().loginName
                                    }
                                    // console.log('updateObj', JSON.stringify(updateObj))
                                    APP.ajax('APP_Upadte_JYFA', updateObj, function (res) {
                                        // console.log('updateres', JSON.stringify(res))
                                        if (res.ds[0].status == '0') {
                                            vm.$toast('提交成功！');
                                            api.sendEvent({
                                                name: 'refresh'
                                            })
                                        }
                                    })
                                    if (api.pageParam.titleName == '检验任务池') {
                                        return
                                    }
                                    else {
                                        if (num == 1) {
                                            var obj = {
                                                Type: num,
                                                FQCCkID: that.formData.FQCCkID
                                            }
                                            console.log('obj', JSON.stringify(obj))
                                            APP.ajax('APP_SHFStockID_1692319956859', obj, function (res) {
                                                console.log('res', JSON.stringify(res))
                                                if (res.ds[0].status == 500) {
                                                    vm.$toast(res.ds[0].msg);

                                                }
                                                else {
                                                    var obj1 = {
                                                        Type: num,
                                                        FkeyID: that.formData.FQCCkID,
                                                    }
                                                    APP.ajax('P_SendPollCheck', obj1, function (res) {
                                                        api.sendEvent({
                                                            name: 'refresh'
                                                        })
                                                        api.closeWin()

                                                    })

                                                }
                                            })
                                        }

                                    }

                                } else {
                                    vm.$toast('提交失败，请重试！');
                                }
                                setTimeout(() => {
                                    that.saveFlag = 1
                                }, 2000)
                            })

                        }

                    }

                    // } 

                    // else if (!that.saveFlag) {
                    //     api.toast({
                    //         msg: '请勿频繁操作！'
                    //     })
                    // }
                },

                submit(flag) {
                    var that = this
                    that.saveRow(flag)

                },

                toOffice(num) {
                    var that = this
                    that.showOffice = true
                    var obj
                    if (num == 1) {
                        obj = {
                            ProductCode: that.formData.XXDDBillNO,
                            Type: num
                        }
                    }
                    else if (num == 2) {
                        obj = {
                            ProductCode: that.formData.XXDDBillNO,
                            Type: num
                        }
                    }
                    else if (num == 3) {
                        obj = {
                            ProductCode: that.formData.KJM,
                            Type: num
                        }
                    }
                    else if (num == 4) {
                        obj = {
                            ProductCode: that.formData.XQDH,
                            Type: num
                        }
                    }
                    console.log('ProductCode', JSON.stringify(obj))
                    APP.ajax('app_getBZSOP', obj, function (res) {
                        console.log('res', JSON.stringify(res))
                        if (res) {
                            const groupedFiles = {};
                            var id = 1
                            for (let i = 0; i < res.ds.length; i++) {
                                res.ds[i].id = id++;
                            }
                            console.log('res', JSON.stringify(res.ds))
                            var children = res.ds
                            // 遍历文件数组  
                            children.forEach(file => {
                                file.FilePath = file.FilePath.replace(/&nbsp;/g, '%C2%A0')
                                file.text = file.FilePath

                                const extension = file.FileTypeName;
                                // 如果groupedFiles中没有这个后缀名的数组，则创建一个新数组并设置标题  
                                if (!groupedFiles[extension]) {
                                    groupedFiles[extension] = {
                                        text: `${extension}`,
                                        children: []
                                    };
                                }
                                // 将文件添加到对应后缀名的数组中  
                                groupedFiles[extension].children.push(file);
                            });

                            // 将groupedFiles转换为数组，如果需要的话  
                            that.officeItems = Object.values(groupedFiles);
                        }

                        console.log(' that.officeItems', JSON.stringify(that.officeItems))
                    })

                },

                onClickNav() {
                    var that = this
                    that.officeActiveId = 0
                },

                onClickItem(val) {
                    var that = this
                    console.log('FilePath' + JSON.stringify(that.serverIP + val.FilePath))
                    api.download({
                        url: that.serverIP + val.FilePath,
                        report: true
                    }, function (downloadRet, err) {
                        console.log(JSON.stringify(downloadRet))
                        if (err) {
                            api.hideProgress();
                            api.toast({
                                msg: '下载失败请重试!',
                                duration: 2000
                            })
                        } else if (downloadRet.state == 0) {
                            api.showProgress({
                                title: downloadRet.percent + '%',
                                modal: false
                            });
                        } else if (downloadRet.state == 1) {
                            api.hideProgress();

                            docReader.open({
                                path: 'file://' + downloadRet.savePath,
                            }, function (ret, err) {
                                console.log(JSON.stringify(ret))
                                console.log(JSON.stringify(err))

                                if (ret.status) {

                                } else {
                                    api.toast({
                                        msg: '文档打开失败' + JSON.stringify(err),
                                        duration: 2000
                                    })
                                }
                            });


                        }
                    })

                },

                openBaseScreen: function (str, index) {
                    var that = this;
                    that.currentIndex = index
                    var obj;
                    if (str == '产品') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: false,
                            searchBy: ['name'],
                            isPaging: false,
                            type: str,
                            cmd: 'SJJ_CPXL',
                            param: {}
                        }
                    } else if (str.indexOf('工序') != -1) {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: false,
                            searchBy: ['name'],
                            isPaging: false,
                            type: str,
                            cmd: 'SJJ_GXXL',
                            param: {}
                        }
                    } else if (str == '检验员') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: false,
                            searchBy: ['name'],
                            isPaging: false,
                            type: str,
                            cmd: 'SJJ_JYYXL',
                            param: {}
                        }
                    } else if (str == '所属分类') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: false,
                            searchBy: ['name'],
                            isPaging: false,
                            type: str,
                            cmd: 'APP_SJJSSFL',
                            param: {}
                        }
                    } else if (str == '检验项目') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: false,
                            searchBy: ['name'],
                            isPaging: false,
                            type: str,
                            cmd: 'APP_SJJJYXMXL',
                            param: {}
                        }
                    } else if (str == '设备') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: false,
                            searchBy: ['name'],
                            isPaging: false,
                            type: str,
                            cmd: 'APP_SJJSBXL',
                            param: {}
                        }
                    } else if (str == '模具') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: false,
                            searchBy: ['name'],
                            isPaging: false,
                            type: str,
                            cmd: 'APP_SJJMJXL',
                            param: {}
                        }
                    } else if (str == '生产人员') {
                        obj = {
                            allowClear: false,
                            showSearch: true,
                            searchKey: '',
                            serverSearch: false,
                            searchBy: ['name'],
                            isPaging: false,
                            type: str,
                            cmd: 'APP_DG_RYXL',
                            param: {}
                        }
                    }
                    api.openWin({
                        name: 'baseScreen',
                        url: '../tool/baseScreen.html',
                        reload: true,
                        slidBackEnabled: false,
                        pageParam: obj
                    })
                },

                //摄像头扫描事件
                openScan() {
                    var resultList = api.hasPermission({
                        list: ['camera']
                    });
                    if (resultList[0].granted) {
                        // 已授权，可以继续下一步操作
                        FNScanner.open({
                            autorotation: true
                        }, function (ret, err) {
                            if (ret) {
                                if (ret.content) {
                                    api.sendEvent({
                                        name: 'scanHandler',
                                        extra: {
                                            scanData: ret.content
                                        }
                                    })
                                }
                            } else {
                                vm.$toast('扫描失败');
                            }
                        });
                    } else {
                        api.confirm({
                            msg: '应用需要您的授权才能访问相机',
                            buttons: ['取消', '去设置']
                        }, function (ret) {
                            if (ret.buttonIndex == 2) {
                                api.requestPermission({
                                    list: ['camera'],
                                }, function (res) {
                                    if (res.list[0].granted) {
                                        // 已授权，可以继续下一步操作
                                        FNScanner.open({
                                            autorotation: true
                                        }, function (ret, err) {
                                            if (ret) {
                                                if (ret.content) {
                                                    api.sendEvent({
                                                        name: 'scanHandler',
                                                        extra: {
                                                            scanData: ret.content
                                                        }
                                                    })
                                                }
                                            } else {
                                                vm.$toast('扫描失败');
                                            }
                                        });
                                    }
                                });
                            }
                        });
                    }


                    // var hwScanner = api.require('hwScanner');
                    // hwScanner.defaultScanner({
                    //     formatType: 'ALL'
                    // }, function (ret) {
                    //     if (ret.status) {
                    //         api.sendEvent({
                    //             name: 'scanHandler',
                    //             extra: {
                    //                 scanData: ret.result
                    //             }
                    //         })
                    //     }
                    //     else {
                    //         vm.$toast('扫描失败');
                    //     }
                    // });
                },

                //打开打印
                openPrint() {
                    if (vm.printConfig) {
                        var script = vm.printConfig.replace(/\['/g, "vm.formData['");
                        script = script.replace(/\["/g, "vm.formData[\"");
                        eval(script);
                    }
                },
            }
        })
    };
</script>

</html>